/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.forms;

import java.awt.event.KeyEvent;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Bone
 */
public class ConcluirContaForm extends javax.swing.JDialog {

    public ConcluirContaForm() {
        initComponents();
        setVisible(true);
    }

    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tituloFormulario1 = new com.bs.extensoesSwing.TituloFormulario();
        dataField = new com.bs.extensoesSwing.CampoData();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setModal(true);
        setUndecorated(true);

        tituloFormulario1.setTitulo("Concluir");

        dataField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        dataField.setText("00000000");
        dataField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                dataFieldKeyReleased(evt);
            }
        });

        jLabel1.setText("Data de pagamento:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tituloFormulario1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dataField, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(tituloFormulario1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(dataField, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void dataFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dataFieldKeyReleased
        if(evt.getKeyCode() == KeyEvent.VK_ENTER){
            setVisible(false);
        }
    }//GEN-LAST:event_dataFieldKeyReleased

    public Date getValor(){
        try {
            SimpleDateFormat f= new SimpleDateFormat("dd/MM/yyyy");
            String d = dataField.getText();
            return f.parse(d);
        } catch (ParseException ex) {
            Logger.getLogger(ConcluirContaForm.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.bs.extensoesSwing.CampoData dataField;
    private javax.swing.JLabel jLabel1;
    private com.bs.extensoesSwing.TituloFormulario tituloFormulario1;
    // End of variables declaration//GEN-END:variables
}
